#include "StdAfx.h"
#include "Passenger.h"


CPassenger::CPassenger(size_t targetFloor)
	: m_target(targetFloor), m_passengerArrivedListener(NULL)
{
}

CPassenger::~CPassenger(void)
{
	if (m_passengerArrivedListener != NULL)
		delete m_passengerArrivedListener;
}

size_t CPassenger::GetTarget() const
{
	return m_target;
}

void CPassenger::NewFloor(size_t floorNum)
{
	if (m_target == floorNum && m_passengerArrivedListener != NULL)
		m_passengerArrivedListener->OnPassengerArrived(this);
}

void CPassenger::RegisterListener(IPassengerListener* listener)
{
	m_passengerArrivedListener = listener;
}